import Vue from 'vue'
import VueRouter from 'vue-router'
// import Login from '@/views/login/login.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import('../views/layout/layout.vue'),
    // 二级路由
    children: [
      { path: '', name: 'home', component: () => import('../views/hone/hone.vue') },
      { path: 'question', name: 'question', component: () => import('../views/question/question.vue') },
      { path: 'video', name: 'video', component: () => import('../views/video/video.vue') },
      { path: 'setting', name: 'setting', component: () => import('../views/setting/setting.vue') }

    ]
  },
  // 登录路由
  {
    path: '/login',
    name: 'login',

    component: () => import('../views/login/login.vue')
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('../search/search.vue')
  },
  {
    path: '/search/result',
    name: 'result',
    component: () => import('../search/result.vue')
  },
  // 文章详情页
  {
    path: '/article/:id',
    name: 'article',
    beforeEnter: (to, from, next) => {
      // ...
      // console.log('路由独享守卫：beforeEnter')
      next()
    },
    component: () => import('../views/article/article.vue')
  },

  {
    path: '/search/profile',
    name: 'profile',
    component: () => import('../views/setting/profile.vue')
  },
  {
    path: '/setting/chat',
    name: 'chat',
    component: () => import('../views/setting/chat.vue')
  }

]

const router = new VueRouter({
  routes
})

export default router
